package Underworld_Survival;

import java.util.Map;
import java.util.function.Consumer;

abstract class Scroll extends Item{
    private transient Consumer<Player> effect; // 关键：使用 Consumer 定义效果

    public Scroll(String itemName, String itemIntroduction, String itemEffect,
                CurrencyType purchaseCurrency, int priceOfPurchaseItem,
                int priceOfSellingItem, Consumer<Player> effect){
        super(itemName,itemIntroduction,itemEffect,purchaseCurrency,priceOfPurchaseItem,priceOfSellingItem);
        this.effect=effect;
    }

    // 触发卷轴效果
    public void applyScrollEffect(Player player) {
        effect.accept(player);
    }
}

//全局卷轴(只有player才能学技能)
//1.铁头功秘法ironHeadSkill_SecretTechnique
class ironHeadSkill_SecretTechnique extends Scroll{
    public ironHeadSkill_SecretTechnique(){
        super("【铁头功秘法】","记载铁头功的学习方法，让头部发挥力量",
                "学会技能铁头功",CurrencyType.GOLD,130, 70,
                player->{player.learnSkill(new ironHeadSkill());});
    }


    @Override
    public String getItemId() { return "scroll_ironHeadSkill_SecretTechnique"; }

}
//2.旋风腿秘法cycloneKick_SecretTechnique
class cycloneKick_SecretTechnique extends Scroll{
    public cycloneKick_SecretTechnique(){
        super("【旋风腿秘法】","介绍旋风腿的学习方法，传闻这招连当今的最强高手也无法躲避",
                "学会技能旋风腿",CurrencyType.GOLD,200, 100,
                player->{player.learnSkill(new cycloneKick());});
    }

    @Override
    public String getItemId() { return "scroll_cycloneKick_SecretTechnique";}

    }
//3.剧毒爪秘法poisonousClaw_SecretTechnique
class poisonousClaw_SecretTechnique extends Scroll{
    public poisonousClaw_SecretTechnique(){
        super("【剧毒爪秘法】","练就百毒之手，侵入对手体内，也不知是否有副作用，乃邪教秘法",
                "学会技能剧毒爪",CurrencyType.DIAMOND,70, 140,
                player->{player.learnSkill(new poisonousClaw());});
    }

    @Override
    public String getItemId() { return "scroll_poisonousClaw_SecretTechnique";}

}
//4.金刚护体秘法invincibleBodyDefense_SecretTechnique
class invincibleBodyDefense_SecretTechnique extends Scroll{
    public invincibleBodyDefense_SecretTechnique(){
        super("【金刚护体秘法】","介绍金刚护体的学习方法，凝金刚之力，万钧重击皆如蚍蜉撼树",
                "学会技能金刚护体",CurrencyType.DIAMOND,60, 120,
                player->{player.learnSkill(new invincibleBodyDefense());});
    }

    @Override
    public String getItemId() { return "scroll_invincibleBodyDefense_SecretTechnique";}

}
//5.万剑归宗秘法ConvergenceOfBlades_SecretTechnique
class convergenceOfBlades_SecretTechnique extends Scroll{
    public convergenceOfBlades_SecretTechnique(){
        super("【万剑归宗秘法】","破碎与重生的轮回，在万剑共鸣中化作最终审判",
                "学会技能万剑归宗",CurrencyType.DIAMOND,80, 160,
                player->{player.learnSkill(new convergenceOfBlades());});
    }

    @Override
    public String getItemId() { return "scroll_convergenceOfBlades_SecretTechnique";}

}
//6.血量卷轴healthScroll
class healthScroll extends Scroll{
    public healthScroll(){
        super("【血量卷轴】","神奇的卷轴，能恢复血量，更能突破血量上限",
                "血量回复+15  血量上限+5",CurrencyType.GOLD,50,20,
                player->{player.refillHP(15);player.modifyAttributes(Map.of(AttributeType.BASE_MAXHP,5f),true);});
    }

    @Override
    public String getItemId() { return "scroll_healthScroll";}

}